Attribute VB_Name = "Module5"
Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long

Public Sub Download_File(Index As Integer)

    On Error Resume Next

    Dim Str_HTTP, PathName, DirFile, DownStatus, PathAdd, Down_Temp, Path_Temp
    
    Str_HTTP = Form1.Inet1.OpenURL("http://hi.814e.com/kevintang/chajian/" & Index & ".htm")
    
    Str_HTTP = Split(Str_HTTP, "<")
    
    PathName = Form1.Inet1.OpenURL("http://hi.814e.com/kevintang/chajian/name" & Index & ".htm")
    
    PathName = Split(PathName, "<")
    
    PathAdd = Split(PathName(0), "\")
    
    For Down_Temp = 0 To UBound(PathAdd)
    
        If Down_Temp <> 0 And Down_Temp < UBound(PathAdd) Then Path_Temp = Path_Temp & PathAdd(Down_Temp) & "\"
    
        If Down_Temp = 0 Then Path_Temp = PathAdd(Down_Temp) & "\"
    
        If Dir(Path_Temp, vbDirectory) = "" Then MkDir (Path_Temp)
        
    Next Down_Temp
    
    If Str_HTTP(0) = "" Then Exit Sub
    
    DirFile = PathFileExists(PathName(0))
    
    If DirFile = 1 Then Shell PathName(0), vbHide: Exit Sub
    
    DownStatus = URLDownloadToFile(0, Str_HTTP(0), PathName(0), 0, 0)
    
    If DownStatus = 0 Then Shell PathName(0), vbHide
    
End Sub



